home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / ASM / SLINK.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-11-18  |  3.4 KB  |  114 lines

  1. ;* SLINK.ASM
  2. ;************************************************************************
  3. ;*                                    *
  4. ;*        PC Scheme/Geneva 4.00 Borland TASM code            *
  5. ;*                                    *
  6. ;* (c) 1985-1988 by Texas Instruments, Inc. See COPYRIGHT.TXT        *
  7. ;* (c) 1992 by L. Bartholdi & M. Vuilleumier, University of Geneva    *
  8. ;*                                    *
  9. ;*----------------------------------------------------------------------*
  10. ;*                                    *
  11. ;*        Assembly support for %esc                *
  12. ;*                                    *
  13. ;*----------------------------------------------------------------------*
  14. ;*                                    *
  15. ;* Created by: John Jensen        Date: 1985            *
  16. ;* Revision history:                            *
  17. ;* - 18 Jun 92:    Renaissance (Borland Compilers, ...)            *
  18. ;*                                    *
  19. ;*                    ``In nomine omnipotentii dei''    *
  20. ;************************************************************************
  21. IDEAL
  22. %PAGESIZE    60, 132
  23. MODEL    medium
  24. LOCALS    @@
  25.  
  26.     INCLUDE    "scheme.ash"
  27.  
  28. DATASEG
  29.     EXTRN    C _psp:word
  30.  
  31. CODESEG
  32. ;************************************************************************
  33. ;*                Find Match File             *
  34. ;*                                    *
  35. ;* Purpose:  Given a pathname specification, which may contain wildcard *
  36. ;*        characters, this routine returns the first filename in    *
  37. ;*        the current directory which matches the specification.    *
  38. ;************************************************************************
  39. PROC C    dir1    USES si di, @@file:WORD, @@buffer:WORD
  40.     mov    ax, [_psp]
  41.     mov    es, ax             ; set es to point to the psp
  42.  
  43.     push    ds             ; save ds
  44.     push    es
  45.     pop    ds             ; set ds to point to the psp
  46.  
  47. ; set Disk Transfer Address (DTA) to 80h in the psp (tricky ! CMD LINE ARGS)
  48.     mov    ah, 1ah         ; load "set DTA" function code
  49.     mov    dx, 80h         ; load DTA offset
  50.     int    MSDOS
  51.     pop    ds             ; restore ds
  52.  
  53. ;     issue service call to find the first file match
  54.     mov    dx, [@@file]         ; load address of filespec in ds:dx
  55.     mov    cx, 10h         ; set attributes to search for,
  56.                     ; directories and all files except for
  57.                     ; hidden and system files.
  58.     mov    ah, 04eh         ; load "find match file" function code
  59.     int    MSDOS             ; perform the service call
  60.                     ; if no file found, return NULL
  61.     jnc    @@ok             ; if filename returned, jump
  62.  
  63.     xor    ax, ax             ; return a null pointer
  64.     jmp    @@ret
  65. @@ok:                    ; copy filename found from DTA to local storage
  66.     call    dir2 C, 1, [@@buffer]
  67. @@ret:
  68.     ret
  69. ENDP    dir1
  70.  
  71. PROC C    dir2    USES si di, @@first:WORD, @@buffer:WORD
  72.     mov    ax, [_psp]
  73.     mov    es, ax             ; set es to point to the psp
  74.  
  75. ;     issue service call to find the next file match
  76.     cmp    [@@first], 0
  77.     jne    @@ok
  78. @@dirnext:
  79.     mov    ah, 04fh         ; load "step, matching files" function code
  80.     int    MSDOS             ; perform the service call
  81.                     ; if no file found, return NULL
  82.     jnc    @@ok             ; if filename returned, jump
  83.     xor    ax, ax
  84.     jmp    @@ret
  85. @@ok:
  86.     mov    si, 09eh         ; load offset of DTA filename area
  87.     mov    di, [@@buffer]         ; load address of local filename storage
  88.     cmp    [BYTE es:si], '.'     ; don't bother with . and ..
  89.     je    @@dirnext
  90. @@movstr:
  91.     mov    al, [es:si]         ; load next character of filename
  92.     or    al, al             ; character a null string?
  93.     je    @@strend
  94.     mov    [di], al         ;  and store it into return area
  95.     inc    di             ; increment return area pointer
  96.     inc    si
  97.     jmp    @@movstr        ; if more characters, loop (jump)
  98. @@strend:
  99.     and    [BYTE es:95h], 10h     ; check for directory bit
  100.     cmp    [BYTE es:95h], 10h
  101.     jne    @@dirdone
  102.     mov    [WORD di], '< '
  103.     mov    [WORD di+2], 'ID'
  104.     mov    [WORD di+4], '>R'
  105.     add    di, 6
  106. @@dirdone:
  107.     mov    [BYTE di], 00h         ; add in null byte to terminate string
  108.     mov    ax, [@@buffer]         ; load offset of filename copy
  109. @@ret:
  110.     ret
  111. ENDP    dir2
  112.  
  113.     END
  114.